package com.cloudkinto.controller.company;


import com.cloudkinto.common.annotations.UserSessionRequired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.cloudkinto.service.company.CompanySecretKeyService;

import com.cloudkinto.common.web.PageResult;
import com.cloudkinto.common.web.SingleResult;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;

import java.util.HashMap;
import java.util.Map;

import com.cloudkinto.base.BaseController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hua
 * @since 2023-06-08
 */
@RestController
@Api(tags = "公司密钥模块")
@RequestMapping("/api/CompanySecretKey")
public class CompanySecretKeyController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(CompanySecretKeyController.class);

    @Autowired
    private CompanySecretKeyService service;


    @UserSessionRequired
    @PostMapping("secret")
    @ApiOperation(value = "新增密钥", notes = "新增密钥")
    public SingleResult secret() {
        Long userId = getCurrentUserId();
        Long companyId = getCompanyId();
        return SingleResult.success("新增成功", service.secret(companyId, userId));
    }

    @GetMapping("getTokenBySecret")
    @ApiOperation(value = "根据密钥获取token", notes = "根据密钥获取token")
    public SingleResult getTokenBySecret(String companyCode, String companySecret) {
        return SingleResult.success("操作成功", service.getTokenBySecret(companyCode, companySecret));
    }


}

